#pragma once
class XStringBuilder
{
private: 
	const XUINT32 MINIMUM_INITIAL_SIZE;
public: 
	XStringBuilder();
	~XStringBuilder();
private: 
	XCHAR * m_pBuffer;
	XUINT32 m_cBuffer;
	XUINT32 m_cActual;
public: 
	HRESULT Initialize(const XCHAR * pBuffer, XUINT32 cBuffer);
	HRESULT Initialize(XUINT32 uInitialSize);
	HRESULT Append(const XCHAR ch);
	HRESULT Append(const XCHAR * pBuffer, XUINT32 cBuffer);
	HRESULT Append(const CXString & rstrToAppend);
	HRESULT Append(const CXString * rstrToAppend);
	HRESULT TrimWhitespace();
	HRESULT ShiftLeft(XUINT32 uAmount);
	HRESULT RemoveString(CXString * * ppstrString);
	HRESULT GetStringCopy(CXString * * ppstrString, XUINT32 uStartIndex);
	HRESULT Reset(XUINT32 uInitialSize, XBOOL bForceShrink);
	const XCHAR * GetBuffer();
	XUINT32 GetCount();
private: 
	HRESULT EnsureBufferForAdding(XUINT32 uNumberOfCharsToBeAdded);
	HRESULT ExpandBuffer(XUINT32 uNewBufferSize);
	XBOOL WillFit(XUINT32 uNumberOfCharsToBeAdded);
	XBOOL IsWhitespaceChar(const XCHAR & ch);
};

